<ul class="message error">
    <?php if ($error != ''): ?>
        <li><?php echo $error ?></li>
    <?php endif; ?>
    <?php echo form_error('link_img') ?>
    <?php echo form_error('title') ?>
    <?php echo form_error('desc') ?>
    <?php echo form_error('content') ?>
</ul>
<form class="form has-validation" method="POST" action="">
    <input type="hidden" name="frmToken" id="frmToken" value="<?php echo $frmToken ?>"/>
    <div class="clearfix">
        <label for="form-url" class="form-label">Tiêu đề<em>*</em><small>Tiêu đề tin</small></label>
        <div class="form-input"><input type="text"  id="form-title" name="title" required="required" value="<?php echo set_value('title') ?>"/></div>
    </div>
    <div class="clearfix">
        <label for="form-upload" class="form-label">Hình ảnh mô tả<em>*</em></label>
        <div class="form-input">
            <input type="text" id="form-upload" name="upload" value="" required="required"/>
        </div>
        <div class="uploadImgResult form-input" style="display:none">
            <p style="color:green;font-weight: bold">Bạn đang sử dụng file : <a href="#" class="img_name"></a></p>
        </div>
    </div>
    <div class="clearfix">
        <label for="form-url" class="form-label">Mô tả<em>*</em><small>Mô tả tin tức</small></label>
        <div class="form-input">
            <textarea rows="5" cols="35" name="desc" id="form-desc" style="width:400px" required="required"><?php echo set_value('desc') ?></textarea>
        </div>
    </div>
    <div class="clearfix">
        <label for="form-url" class="form-label">Nội dung<em>*</em><small>Nội dung tin tức</small></label>
        <div class="form-input">
            <textarea rows="10" cols="70" name="content" class="content" id="form-content"><?php echo set_value('content') ?></textarea>
            <input type="ckeditor" class="tmpContent" name="tmpContent" id="tmpContent" style="width:1px;height:1px;outline:none;border:none;background:none"/>
        </div>
    </div>

    <div class="form-action clearfix">
        <input class="button" type="submit" name="submit" data-icon-primary="ui-icon-circle-check" value="OK"/>
        <input class="button" type="reset" value="Nhập lại"/>
    </div>
</form>

<script type="text/javascript">
    $(document).ready(function() {
        $(".content").ckeditor();
        $.tools.validator.fn("[type=ckeditor]", "Không được để trống !", function (input, value) {
            var summary = CKEDITOR.instances['form-content'].getData();
            if(summary == '' || summary.length < 30)
                return false;
            return true;
        });
        
        $("#form-upload").click(function() {
            var finder = new CKFinder( { width : 600 } ),
                obj = $(this);
            finder.selectActionFunction = function(fileUrl, data) {
                var re = /^.*\/(.*\.(jpg|png|gif|jpeg))$/g,
                    match = re.exec(fileUrl),
                    uploadResult = $('.uploadImgResult');
                obj.val(fileUrl);
                if(match && match[1] !== undefined) {
                    uploadResult.find('.img_name').html(match[1]).attr('href', base_url + fileUrl);
                    uploadResult.show();
                }
            };
            finder.basePath = '/Images/';
            finder.resourceType = "Images";
            finder.popup(800,600);
        });
    });
</script>
   